package com.cuit.dao;

import com.cuit.doamin.Admin;
import com.cuit.doamin.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface AdminDao {
    /**
     * 查询所有管理员
     *
     * @return
     */
    @Select("select * from admin")
    public List<Admin> findAll();

    /**
     * 根据名字查询用户
     *
     * @return
     */
    @Select("select * from user where u_name = #{u_name} and u_pwd = #{u_pwd}")
    public User findByUname(User user);

    /**
     * 根据名字查询管理员
     *
     * @return
     */
    @Select("select * from admin where a_name = #{a_name} and a_pwd = #{a_pwd}")
    public Admin findByAname(Admin admin);

    /**
     * 修改密码
     *
     * @return
     */
    @Update("update admin set a_pwd = #{a_pwd} where a_name = #{a_name}")
    public int updatePwd(@Param("a_name") String name, @Param("a_pwd") String pwd);
}
